﻿@using System.Globalization
@model WebApplication.Models.Work

@{
    ViewBag.Title = "Work " + Model.name;
    List<SelectListItem> state = new List<SelectListItem>
    {
      new  SelectListItem()
      {
          Text="new",
          Value="0",
          Selected=Model.state==0,
          Disabled=!(Model.state==0)
      },
      new  SelectListItem()
      {
          Text="run",
          Value="1",
          Selected=Model.state==1,
          Disabled=!(Model.state!=2)
      },
      new  SelectListItem()
      {
          Text="suspended",
          Value="3",
          Selected=Model.state==3,
          Disabled=!(Model.state==1),
      },
      new  SelectListItem()
      {
          Text="completed",
          Value="2",
          Selected=Model.state==2,
          Disabled=false,
      },



    };
}

<h2>Work @Html.Label(Model.name)</h2>


@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()

    <div class="form-horizontal">

        <hr/>

        <div class="form-group">
            @Html.LabelFor(model => model.name, htmlAttributes: new {@class = "control-label col-md-2"})
            <div class="col-md-10">
                @Html.EditorFor(model => model.name, new {htmlAttributes = new {@class = "form-control"}})
                @Html.ValidationMessageFor(model => model.name, "", new {@class = "text-danger"})
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.note, htmlAttributes: new {@class = "control-label col-md-2"})
            <div class="col-md-10">
                @Html.EditorFor(model => model.note, new {htmlAttributes = new {@class = "form-control"}})
                @Html.ValidationMessageFor(model => model.note, "", new {@class = "text-danger"})
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.startTime, htmlAttributes: new {@class = "control-label col-md-2"})
            <div class="col-md-10">
                @Html.Label(Model.startTime.ToString(), new {htmlAttributes = new {@class = "form-control"}})

            </div>
        </div>

        <div class="form-group">
            @Html.Label("Dataset", htmlAttributes: new {@class = "control-label col-md-2"})
            <div class="col-md-10">
                @Html.ActionLink(Model.DataSet.name, "Edit/" + Model.idDataSet, "DataSet")

            </div>
        </div>


        <div class="form-group">
            @Html.Label("Thraining method", htmlAttributes: new {@class = "control-label col-md-2"})
            <div class="col-md-10">
                @{
                    if (Model.param.Split(';').Length >= 1)
                    {
                        Write(Model.param.Split(';')[0]);
                    }
                }

            </div>
        </div>

        <div class="form-group">
            @Html.Label("Function hiden", htmlAttributes: new {@class = "control-label col-md-2"})
            <div class="col-md-10">
                @{
                    if (Model.param.Split(';').Length >= 2)
                    {
                        Write(Model.param.Split(';')[1]);
                    }
                }

            </div>
        </div>
        <div class="form-group">
            @Html.Label("Function output", htmlAttributes: new {@class = "control -label col-md-2"})
            <div class="col-md-10">
                @{
                    if (Model.param.Split(';').Length >= 3)
                    {
                        Write(Model.param.Split(';')[2]);
                    }
                }

            </div>
        </div>
        <div class="form-group">
            @Html.Label("Layers", htmlAttributes: new {@class = "control -label col-md-2"})
            <div class="col-md-10">
                @{
                    if (Model.param.Split(';').Length >= 4)
                    {
                        Write(Model.param.Split(';')[3]);
                    }
                }

            </div>
        </div>
        <div class="form-group">
            @Html.Label("Max epoch", htmlAttributes: new {@class = "control -label col-md-2"})
            <div class="col-md-10">
                @{
                    if (Model.param.Split(';').Length >= 5)
                    {
                        Write(Model.param.Split(';')[4]);
                    }
                }

            </div>
        </div>
        <div class="form-group">
            @Html.Label("Save ever epoch", htmlAttributes: new {@class = "control -label col-md-2"})
            <div class="col-md-10">
                @{
                    if (Model.param.Split(';').Length >= 6)
                    {
                        Write(Model.param.Split(';')[5]);
                    }
                }

            </div>
        </div>





        <div class="form-group">
            @Html.LabelFor(model => model.state, htmlAttributes: new {@class = "control-label col-md-2"})
            <div class="col-md-10">
                @Html.DropDownList("state", state)
            </div>
        </div>

        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="submit" value="Save" class="btn btn-default"/>
            </div>
        </div>
    </div>
}
    <div>
        <img src="@Url.Action("GetChart/"+Model.id)" />
    </div>




    <h2>Temp Ann</h2>

    <hr />
            <table class="table">
                <tr>
                    <th>
                        @Html.DisplayName("Step")
                    </th>
                    <th>
                        @Html.DisplayName("Value")
                    </th>
                    <th>
                        @Html.ActionLink("Delete all", "Clear/" + Model.id, "Temp")
                    </th>
                </tr>

                @foreach (var item in Model.Temp.OrderBy(t =>Convert.ToDouble( t.test)))
                {
                    <tr>

                        <td>
                            @Html.DisplayName(item.stap.ToString())
                        </td>
                        <td>
                            @Html.DisplayName(item.test)
                        </td>
                        <td>
                            @Html.ActionLink("Save", "Create/" + item.id, "Ann")
                        </td>
                    </tr>
                }
            </table>

<h2>Complit Ann</h2>

<hr />
<table class="table">
    <tr>
        <th>
            @Html.DisplayName("Name")
        </th>
        <th>
            @Html.DisplayName("Time")
        </th>

        <th>
            @Html.DisplayName("Error")
        </th>
        <th></th>
    </tr>

    @foreach (var item in Model.Ann)
    {
        <tr>
            <td>
                @Html.ActionLink(item.name, "Edit/" + item.id, "ANN")


            </td>

            <td>
                @Html.DisplayName(item.dateTime.ToString(CultureInfo.CurrentCulture))
            </td>


            <td>
                @Html.DisplayName(item.test != null ? item.test : "")
            </td>

        </tr>
    }

</table>

<div>
    @Html.ActionLink("Back to List", "Index")
</div>


@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}
